package com.example.babymonitor;

import com.example.babymonitor.R;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class callForward extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_callforward);
		
		final Intent yesOrNo = new Intent(this, serverSetup.class);
		
		Button yesButton = (Button) findViewById(R.id.callforward_yesCallforward);
		yesButton.setOnClickListener(new Button.OnClickListener() {
		    public void onClick(View v) {
		    	EditText mEdit   = (EditText)findViewById(R.id.callforward_phonenumber);
				String phone = mEdit.getText().toString();
				
				
				Intent intent = new Intent(Intent.ACTION_CALL);            
				String prefix = Uri.encode("*21*");
				String postfix = Uri.encode("#");
				intent.setData( Uri.parse("tel:"+prefix+phone+postfix));  
				startActivity(intent);
				
				
				
		    }
		});
		
		Button noButton = (Button) findViewById(R.id.callForward_noCallForward);
		noButton.setOnClickListener(new Button.OnClickListener() {

			@Override
			public void onClick(View v) {
				startActivity(yesOrNo);// TODO Auto-generated method stub
				
				
			}
			
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.callforward, menu);
		return true;
	}

}
